From: Alex Crichton Date: Mon, 21 May 2018 19:57:25 +0000 (-0700) Subject: Copy `--all-features` request to all workspace members X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~1^2~1^2~1 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=3bb99cc91d4144bda7dd6adfe56a4b432a2ea298;p=cargo.git Copy `--all-features` request to all workspace members This fixes an accidental regression introduced in #5012 where the `--all-features` CLI flag was only propagated to the "main crate" as opposed to all workspace packages. This behavior has [already been deemed][pr] as "basically not what you want", but for now it's best to avoid the regression. Closes #5518 [pr]: https://github.com/rust-lang/cargo/pull/5353 --- diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index 8df8e4da6..5a700a7d2 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -272,11 +272,11 @@ pub fn resolve_with_previous<'a, 'cfg>( // workspace, then we use `method` specified. Otherwise we use a // base method with no features specified but using default features // for any other packages specified with `-p`. - Method::Required { dev_deps, .. } => { + Method::Required { dev_deps, all_features, .. } => { let base = Method::Required { dev_deps, features: &[], - all_features: false, + all_features, uses_default_features: true, }; let member_id = member.package_id(); diff --git a/tests/testsuite/features.rs b/tests/testsuite/features.rs index 3312595de..dcd8b6e28 100644 --- a/tests/testsuite/features.rs +++ b/tests/testsuite/features.rs @@ -2031,3 +2031,42 @@ fn only_dep_is_optional() { execs().with_status(0), ); } + +#[test] +fn all_features_all_crates() { + Package::new("bar", "0.1.0").publish(); + + let p = project("foo") + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.0.1" + authors = [] + + [workspace] + members = ['bar'] + "#, + ) + .file("src/main.rs", "fn main() {}") + .file( + "bar/Cargo.toml", + r#" + [project] + name = "bar" + version = "0.0.1" + authors = [] + + [features] + foo = [] + "#, + ) + .file("bar/src/main.rs", "#[cfg(feature = \"foo\")] fn main() {}") + .build(); + + assert_that( + p.cargo("build --all-features --all"), + execs().with_status(0), + ); +}